package com.ruoyi.product.mapper;

import java.util.List;
import com.ruoyi.product.domain.ProductComments;
import com.ruoyi.product.domain.vo.CommentHf;
import com.ruoyi.product.domain.vo.ProductXX;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


/**
 * 评价表Mapper接口
 * 
 * @author ruoyi
 * @date 2024-07-29
 */
public interface ProductCommentsMapper 
{
    /**
     * 查询评价表
     * 
     * @param id 评价表主键
     * @return 评价表
     */
    public ProductComments selectProductCommentsById(Long id);

    /**
     * 查询评价表列表
     * 
     * @param productComments 评价表
     * @return 评价表集合
     */
    public List<ProductComments> selectProductCommentsList(ProductComments productComments);

    /**
     * 新增评价表
     * 
     * @param productComments 评价表
     * @return 结果
     */
    public int insertProductComments(ProductComments productComments);

    /**
     * 修改评价表
     * 
     * @param
     * @return 结果
     */
    @Insert("insert into comment_hf (hf,pid) values (#{hf},#{pid})")
    public int updateProductComments(CommentHf commentHf);

    /**
     * 删除评价表
     * 
     * @param id 评价表主键
     * @return 结果
     */
    public int deleteProductCommentsById(Long id);

    /**
     * 批量删除评价表
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteProductCommentsByIds(Long[] ids);

    @Select("select * from comment_hf where pid=#{hfnr}")
    CommentHf selectComment(Long hfnr);

    @Update("update comment_hf set hf=#{hf} where pid=#{pid}")
    int updateComment(CommentHf commentHf);

    @Select("select b.id,b.image,b.product_name 'productName',m.sort,b.unit,s.image 'specImage',s.volume, " +
            "s.weight,s.inventory,b.status,d.detail from basic b left join specification s on s.snowflakes_id=b.basic_snowflakes_id " +
            "left join marketing m on m.snowflakes_id=b.basic_snowflakes_id" +
            " left join details d on b.basic_snowflakes_id=d.snowflakes_id;")
    List<ProductXX> selectProductList();

    @Update("update product_comments set hfnr=#{id} where id=#{id}")
    int updateCommentsProduct(Long id);
}
